<template>
	<view>
		<uni-section :title="item.itemName" type="line"></uni-section>
		<view v-for="pic in picture">
			<image :src="pic" @click="previewPhoto(pic)"></image>
			
		</view>
		<button v-if="item.schedule!='满意'" class="mini-btn" type="primary"  size="mini" style="margin-top: 30px; margin-left: 10%" @click="tongyi">同意</button>
		<button v-if="item.schedule!='满意'" class="mini-btn" style="margin-left: 70%; top: -35px;" type="primary" size="mini" @click="jujue">拒绝</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				item:'',
				picture:''
			}
		},
		onLoad:function(option){
			this.item = JSON.parse(option.item);
			this.getPicture();
		},
		methods: {
			getPicture:function(){
				uni.request({
					url:'http://'+global.address+':8081/picture/selectpic/'+this.item.itemId,
					method:"GET",
					success: (res) => {
						this.picture = res.data;
					}
				})
			},
			tongyi:function(){
				uni.request({
					url:"http://"+global.address+":8081/items/changeSchedule/"+this.item.itemId+"/满意",
					method:"PUT",
					success(res) {
						if(res.data===1){
							uni.showToast({
								icon:"loading",
								title:"提交成功",
								duration:500
							})
							setTimeout(function(){
								uni.navigateBack({
									delta:1
								})
							},510)
						}
					}
				})
			},
			jujue:function(){
				uni.navigateTo({
				    url:"../../PersonalCenter/dissatisfied?itemId="+this.item.itemId,
				})
				
			},
			previewPhoto(path) {
				let imgs = [];
				imgs.push(path)
				uni.previewImage({
					urls: imgs,
					longPressActions: {
						itemList: ['发送给朋友', '保存图片', '收藏'],
						success: function(data) {
							console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
						},
						fail: function(err) {
							console.log(err.errMsg);
						}
					}
				});
			}
		}
	}
</script>

<style>

</style>
